﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WebApplication1.Interfaces;
using WebApplication1.Models;
namespace WebApplication1.Controllers
{
     

    [ApiController]    
    [Route("api/[controller]/[action]")]

    public class ValuesController : ControllerBase
    {
        private readonly ILegacyService _legacyService;


        public ValuesController(ILegacyService legacyService)
        {
            _legacyService = legacyService;
        }

        [HttpPost]
        public async Task<ActionResult<string>> Post([FromBody] string input)
        {
            var result = await _legacyService.CallLegacyMethodAsync(input);
            return Ok(result);
        }


        //[HttpPost]
        //public async Task<ActionResult<string>> Post([FromBody] LoginModel input)
        //{
        //    var result = await _legacyService.CallLegacyMethodAsync(input.username);
        //    return Ok(result);
        //}


        [HttpPost]
        public async Task<ActionResult> Login([FromQuery] string input)
        {
            var result = await _legacyService.CallLegacyMethodAsync(input);
            return Ok(result);
        }


        [HttpPost]
        public async Task<ActionResult> Login2([FromQuery] LoginModel username)
        {
            var result = await _legacyService.CallLegacyMethodAsync(username.username);
            return Ok(result);
        }


        [HttpPost]
        public async Task<ActionResult> Login3([FromBody] LoginModel username)
        {
            var result = await _legacyService.CallLegacyMethodAsync(username.username);
            return Ok(result);
        }







        //[HttpPost] 
        //public ActionResult abc([FromBody] LoginModel req)
        //{
        //    // var result =  _legacyService.CallLegacyMethodAsync(req.username);
        //    var result = "abc";
        //    return Ok(result); // 返回给调用者，比如浏览器或
        //}





        //[HttpPost] 
        //public async Task<ActionResult<string>> Login2([FromQuery] string input)
        //{
        //    var result = await _legacyService.CallLegacyMethodAsync(input);
        //    return Ok(result); // 返回给调用者，比如浏览器或 Postman
        //}

    }




}
